<?php

  //////////////////////////////////////////////////////////////////
  // OrbitFAQ                                                     //
  // ---------                                                    //
  //                                                              //
  // Orbit FAQ was solely written and developed by Orbit Services //
  // http://www.orbitservices.net                                 //
  //                                                              //
  // Access the Forum here:                                       //
  // http://forums.orbitservices.net/index.php?c=4                //
  //                                                              //
  // OrbitFAQ utilises the following opensource projects/classes; //
  //  + Fckeditor - http://www.fckeditor.net                      //
  //  + Smarty Template Engine - http://smarty.php.net            //
  //  + Swift Email Class - http://www.swiftmailer.org/           //
  //  + OWASP PHP Filter Project - http://www.owasp.org           //
  //  + MySQL Search Class by Stephen Bartholomew                 //
  //                                                              //
  //////////////////////////////////////////////////////////////////

  $smarty->assign("OrbitFAQTitle","Help Guide");

  $folder = "modules/help/files";
  if ($handle = opendir($folder)) {
     while (false !== ($file = readdir($handle))) {
         if ($file != "." && $file != ".." && $file != "manual_images" && $file != "woas.css") {

           $ourfiles[] = $file;

         }
     }
     closedir($handle);
  }

  asort($ourfiles);

  foreach($ourfiles as $file)
    {

      $pieces = explode(" ", $file, 2);
      $number = $pieces[0];
      $title =  $pieces[1];

      $number_count = 0;

      $number_pieces = explode(".", $number);
      foreach($number_pieces as $numbers)
        {
          $number_count++;
        }

      $number_count = ($number_count-1);

      $indent = (8*$number_count);

      $title_pieces = explode(".", $title);
      $actual_title = $title_pieces[0];

      // Build Smarty Content Array
       $smarty_file_array[] = array(
          "manual_number_indent" => "$indent",
          "manual_number" => "$number",
          "manual_title" => "$actual_title",
          "manual_file" => "$file"
        );

    }

  $manual = $_GET['manual'];
  if($manual == '')
    {
      $folder = "modules/help/files";
      if ($handle = opendir($folder)) {
         while (false !== ($file = readdir($handle))) {
             if ($file != "." && $file != ".." && $file != "manual_images" && $file != "woas.css") {

               $manual = $file;
               break;

             }
         }
         closedir($handle);
      }
    }

  // Get Our Manual File
  $manfile = "modules/help/files/$manual";

  // open the manual file
  $handle = fopen($manfile, "r");

  // read the file to a variable
  $manfile_detail = fread($handle, '150000');

  // Replace our known issues
  $manfile_detail = str_replace ( "%5C", "/", $manfile_detail );
  $manfile_detail = str_replace ( "\\", "/", $manfile_detail );
  $manfile_detail = str_replace ( "manual_images/", "modules/help/files/manual_images/", $manfile_detail );
  //$manfile_detail = str_replace ( "woas.css", "modules/help/files/woas.css", $manfile_detail );

  // close the handle
  fclose($handle);

  $smarty->assign('ManualFiles',$smarty_file_array);
  $smarty->assign('ManualDetails',$manfile_detail);

  $smarty_template_file = "$AdminFullPath/skins/$AdminSkin/mod_help.tpl";

?>